/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nite.gestures;

import com.primesense.NITE.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.OpenNI.GeneralException;
import org.OpenNI.IObservable;
import org.OpenNI.IObserver;

/**
 *
 * @author xvanek9
 */
public class WaveGesture extends AbstractGesture {
        PrimaryPointUpdateObserver obs;

    public PrimaryPointUpdateObserver getObs() {
        return obs;
    }

    public void setObs(PrimaryPointUpdateObserver obs) {
        this.obs = obs;
    }
    
    
    WaveDetector wd = null;
    
    public WaveDetector init(){
        try {
            wd = new WaveDetector();
            wd.getWaveEvent().addObserver(new WaveObserver());
            wd.getActivateEvent().addObserver(new ActivateObserver());
            wd.getDeactivateEvent().addObserver(new DeactivateObserver());
            wd.getMessageUpdateEvent().addObserver(new MessageUpdateObserver());
            wd.getNoPointsEvent().addObserver(new NoPointsObserver());
            wd.getPointCreateEvent().addObserver(new PointCreateObserver());
            wd.getPointDestroyEvent().addObserver(new PointDestroyObserver());
            wd.getPointUpdateEvent().addObserver(new PointUpdateObserver());
            wd.getPrimaryPointCreateEvent().addObserver(new PrimaryPointCreateObserver());
            wd.getPrimaryPointDestroyEvent().addObserver(new PrimaryPointDestroyObserver());
            wd.getPrimaryPointReplaceEvent().addObserver(new PrimaryPointReplaceObserver());
            wd.getPrimaryPointUpdateEvent().addObserver(new PrimaryPointUpdateObserver());
            obs = new PrimaryPointUpdateObserver();
            wd.getPrimaryPointUpdateEvent().addObserver(obs);
        } catch (GeneralException ex) {
            Logger.getLogger(WaveGesture.class.getName()).log(Level.SEVERE, null, ex);
        }
        return wd;
    }
    
    private class WaveObserver implements IObserver<NullEventArgs> {
        @Override
        public void update(IObservable<NullEventArgs> io, NullEventArgs args) {
            System.out.println("You wawed now");
        }
    }

    public IObservable<HandEventArgs> getPointUpdateObserver (){
        return wd.getPrimaryPointUpdateEvent();
    }
    
}
